<template>
	<mescroll-uni ref="mescrollRef" :height="height + 'px'" @init="mescrollInit" @down="downCallback" @up="upCallback">
		<!--  -->
		<user-hebavior-item v-for="item in list" :key="item.user.user_id" :item="item" :type="type" @handle="refreshData"></user-hebavior-item>
	</mescroll-uni>
</template>

<script>
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
import userHebaviorItem from './user-hebavior-item.vue';
export default {
	mixins: [MescrollMixin], // 使用mixin
	components: { userHebaviorItem },
	props: {
		height: {
			default: null,
			type: Number
		},
		type: {
			default: 'fans',
			type: String
		}
	},
	data() {
		return {
			list: [],
			apiList: {
				fans: 'getUserFans',
				favors: 'getUserFavors'
			}
		};
	},
	methods: {
		upCallback(mescroll) {
			this.$u.api[this.apiList[this.type]](mescroll.num).then(res => {
				if (mescroll.num == 1) {
					this.list = res.data.list.data;
				} else {
					this.list.push(res.data.list.data);
				}
				this.mescroll.endBySize(res.data.list.data.length, res.data.list.total);
			});
		},
		refreshData() {
			this.mescroll.resetUpScroll(true);
		}
	}
};
</script>

<style lang="scss">
.behavior-item {
	height: 150rpx;
	padding: 25rpx 50rpx;
	background: #fff;
	display: flex;
	align-items: center;
}
</style>
